#include <iostream>
#include "miniutil/scope.h"
#include "miniutil/strutil.h"
#include "minitest/testcase.h"

using namespace miniutil::util;

class testscope:public testcase
{
public:
	testscope()
	{
	}
	

	virtual void test()
	{
        testsplit();
	}

    void testscopeinst()
    {
		Scope<int> onescope;
		onescope.addScope(std::make_pair(10, 100));
		onescope.addScope(std::make_pair(0, 22));
		onescope.addScope(std::make_pair(99, 30));
        onescope.addScope(std::make_pair(1000, 1000));

        bool bret = onescope.hasScope(std::make_pair(20, 20));
        if(bret == false)
        {
            std::cout<<"Has Scope FAIL! SHOULD BE TRUE"<<std::endl;
        }
        else
        {
            std::cout<<"FIND IT!"<<std::endl;
        }
		printscope(onescope);
    }

    void testsplit()
    {
        std::vector<std::string> vparas;
        vparas = miniutil::strutil::split("a/b/c/d", "/");
        std::cout<<vparas.size()<<std::endl;
        for(int i=0; i< vparas.size(); i++)
            std::cout<<vparas[i]<<" ";
        std::cout<<std::endl;

        vparas = miniutil::strutil::split("a/b/c/d", "/");
        std::cout<<vparas.size()<<std::endl;
        for(int i=0; i< vparas.size(); i++)
            std::cout<<vparas[i]<<" ";
        std::cout<<std::endl;

        vparas = miniutil::strutil::split("a/b/c/d", "/");
        std::cout<<vparas.size()<<std::endl;
        for(int i=0; i< vparas.size(); i++)
            std::cout<<vparas[i]<<" ";
        std::cout<<std::endl;

    }

	template <class TN>
	void printscope(typename Scope<TN> &onescope)
	{
		std::list<Scope<int>::SCOPE_PAIR> curscopes = onescope.getScopes();
		for(std::list<Scope<int>::SCOPE_PAIR>::iterator iter = curscopes.begin();
			iter != curscopes.end(); iter ++)
		{
			std::cout<<iter->first<<":"<<iter->second<<std::endl;
		}
	}

//int main()
//{
//	Scope<int> onescope;
//	onescope.addScope(std::make_pair(10, 100));
//	onescope.addScope(std::make_pair(0, 22));
//	onescope.addScope(std::make_pair(99, 30));
//	printscope(onescope);
//	return 0;
//}
};

testcase * testscope1 = new testscope();
